import cv2
import copy
def show_img(img_path,label_path):
    img=cv2.imread(img_path)
    with open(label_path,"r") as f:
        info_list=f.readlines()
    h,w=img.shape[0],img.shape[1]
    info=[]
    for i in info_list:
        info.append({"class":i.split(" ")[0],"p":[float(i.split(" ")[1]),float(i.split(" ")[2]),float(i.split(" ")[3]),float(i.split(" ")[4][0:-1])]})
    for i in info:
        x_center, y_center, w_1, h_1=i["p"]
        cv2.rectangle(img, (int(w*x_center-w*w_1/2), int(h*y_center-h*h_1/2)), (int(w*x_center+w*w_1/2), int(h*y_center+h*h_1/2)), (0, 200, 0), 2)
    cv2.imshow(img_path,img)
    cv2.waitKey(0)
show_img("1.jpg","1.txt")
show_img("1_1.jpg","1_1.txt")